import random
import matplotlib.pyplot as plt#导入模块
import numpy as np

from timeit import timeit#导入timeit.timeit

# plt.hist(np.random.normal(loc=0.0, scale=1.0, size=1000), bins=30)#bins直方图的柱数
# plt.show()
#
# print(type(np.random.normal(loc=0.0, scale=1.0, size=1000)))
#

stock_data = np.random.normal(loc=10.0, scale=1.0, size=1000)
# print("stock_data：\n {}".format(stock_data))

stock_data = np.around(stock_data,2)#保留2位小数
# print("stock_data：\n {}".format(stock_data))

pct_change = np.around((stock_data - np.roll(stock_data,1))/np.roll(stock_data,1),2)
pct_change[0] = np.nan
print("pct_change：\n {}".format(pct_change))